<template>
  <div class="dataVisualize-box">
    <div class="card top-box">
      <div class="top-title">数据可视化</div>
      <div class="top-content">
        <el-row :gutter="40">
          <el-col class="mb40" :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <div class="item-left sle">
              <span class="left-title">患者总数</span>
              <div class="img-box">
                <img src="./images/book-sum.png" alt="" />
              </div>
              <span class="left-number">{{ Hzcounr }}</span>
            </div>
          </el-col>
          <el-col class="mb40" :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
            <div class="item-center">
              <div class="gitee-traffic traffic-box">
                <div class="traffic-img">
                  <img src="./images/add_team.png" alt="" />
                </div>
                <span class="item-value">待复诊</span>
                <!-- <span class="traffic-name sle">待复诊</span> -->
              </div>
              <div class="gitHub-traffic traffic-box">
                <div class="traffic-img">
                  <img src="./images/today.png" alt="" />
                </div>
                <span class="item-value">今日就诊</span>
                <!-- <span class="traffic-name sle">今日就诊</span> -->
              </div>
              <div class="today-traffic traffic-box">
                <div class="traffic-img">
                  <img src="./images/book_sum.png" alt="" />
                </div>
                <span class="item-value">待随访</span>
                <!-- <span class="traffic-name sle">带随访</span> -->
              </div>
              <div class="yesterday-traffic traffic-box">
                <div class="traffic-img">
                  <img src="./images/add_person.png" alt="" />
                </div>
                <span class="item-value" @click="addbutton">新增患者</span>
                <!-- <span class="traffic-name sle">新增患者</span> -->
              </div>
            </div>
          </el-col>
          <el-col class="mb40" :xs="24" :sm="24" :md="24" :lg="10" :xl="10">
            <div class="item-right">
              <div class="echarts-title">糖尿病分型分布</div>
              <div class="book-echarts">
                <Pie ref="pieRef" />
              </div>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <div class="card bottom-box">
      <div class="curve-echarts">
        <Curve ref="curveRef" />
      </div>
    </div>
    <Addzj ref="addzjComponent" @addConten="Addconten" v-if="showaddtc" />
  </div>
</template>
<script setup name="dataVisualize">
import { nextTick, ref } from "vue";
import Curve from "./curve.vue";
import Pie from "./pie.vue";
import Addzj from "./add.vue";
import { getAllTotal } from "@/api/system/system.js";
import { addxzhzApi } from "@/api/hzmange/index.js";
import { ElMessage, ElMessageBox } from "element-plus";
const tabActive = ref(1);
let showaddtc = ref(false);
const tab = [
  { label: "未来7日", name: 1 },
  { label: "近七日", name: 2 },
  { label: "近一月", name: 3 },
  { label: "近三月", name: 4 },
  { label: "近半年", name: 5 },
  { label: "近一年", name: 6 }
];
const addzjComponent = ref(null);

const addbutton = async () => {
  showaddtc.value = true;
  await nextTick();
  addzjComponent.value.open();
};

const Addconten = val => {
  addxzhzApi(val).then(res => {
    if (res.code == 200) {
      ElMessage({
        message: "新增成功!",
        type: "success"
      });
    }
  });
};
gethzCount();
let Hzcounr = ref(0);
async function gethzCount() {
  let { total } = await getAllTotal();
  Hzcounr.value = total;
}
</script>

<style scoped lang="scss">
.dataVisualize-box {
  .top-box {
    box-sizing: border-box;
    padding: 25px 40px 0;
    margin-bottom: 10px;
    .top-title {
      margin-bottom: 10px;
      font-family: DIN;
      font-size: 18px;
      font-weight: bold;
    }
    .top-content {
      margin-top: 10px;
      .item-left {
        box-sizing: border-box;
        height: 100%;
        padding: 40px 0 30px 30px;
        overflow: hidden;
        color: #ffffff;
        background: url("./images/book-bg.png");
        background-position: 50%;
        background-size: cover;
        border-radius: 20px;
        .left-title {
          font-family: DIN;
          font-size: 25px;
        }
        .img-box {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 90px;
          height: 90px;
          margin: 40px 0 20px;
          background-color: #ffffff;
          border-radius: 20px;
          box-shadow: 0 10px 20px rgb(0 0 0 / 14%);
          img {
            width: 60px;
            height: 65px;
          }
        }
        .left-number {
          overflow: hidden;
          font-family: DIN;
          font-size: 62px;
        }
      }
      .item-center {
        display: flex;
        flex-wrap: wrap;
        place-content: space-between space-between;
        height: 100%;
        .traffic-box {
          box-sizing: border-box;
          display: flex;
          flex-direction: column;
          width: 47%;
          height: 48%;
          padding: 25px;
          border-radius: 30px;
          .traffic-img {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 70px;
            height: 70px;
            margin-bottom: 10px;
            background-color: #ffffff;
            border-radius: 19px;
          }
        }
        img {
          width: 33px;
          height: 33px;
        }
        .item-value {
          margin-bottom: 4px;
          font-family: DIN;
          font-size: 28px;
          font-weight: bold;
          color: #ffffff;
          cursor: pointer;
        }
        .traffic-name {
          overflow: hidden;
          font-family: DIN;
          font-size: 20px;
          color: #1a1a37;
          white-space: nowrap;
        }
        .gitee-traffic {
          background: url("./images/1-bg.png");
          background-color: #69bd72;
          background-size: 100% 100%;
        }
        .gitHub-traffic {
          background: url("./images/2-bg.png");
          background-color: #897db1;
          background-size: 100% 100%;
        }
        .today-traffic {
          background: url("./images/3-bg.png");
          background-color: #b28960;
          background-size: 100% 100%;
        }
        .yesterday-traffic {
          background: url("./images/4-bg.png");
          background-color: #4c637d;
          background-size: 100% 100%;
        }
      }
      .item-right {
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 430px;
        border: 1px solid var(--el-border-color);
        border-radius: 25px;
        .echarts-title {
          padding: 15px 20px;
          font-family: DIN;
          font-size: 18px;
          font-weight: bold;
          border-bottom: 1px solid var(--el-border-color);
        }
        .book-echarts {
          flex: 1;
          width: 100%;
        }
      }
    }
  }
  .bottom-box {
    position: relative;
    padding: 0;
    .top-title {
      padding: 0 50px;
      font-family: DIN;
      font-size: 18px;
      font-weight: bold;
    }
    .curve-echarts {
      box-sizing: border-box;
      width: 100%;
      height: 230px;
    }
  }
}
</style>
